package com.wyd.utils;

import java.util.concurrent.atomic.AtomicInteger;

public class SeqUtil {

    private final static AtomicInteger atomic = new AtomicInteger(0);

    private static String startFormat(String format) {
        return String.format(format, atomic.incrementAndGet());
    }

    public static String getId() {
        int increNum = getIncreNum();
        String format = String.format("%05d", increNum);
        String mMddHHmmss = DateUtils.format(DateUtils.nowLdt(), "MMddHHmmss");
        String randomNumStr = IDUtils.getRandomNumStr(5);
        return mMddHHmmss + randomNumStr + format;
    }

    private static synchronized int getIncreNum() {
        if (atomic.get() == 99999) {
            atomic.set(0);
        }
        int i = atomic.addAndGet(1);
        return i;
    }

    public static void main(String[] args) {
        String id = getId();
        System.out.println(id);
    }


}
